package com.cesce.batch.cobros.items;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import com.cesce.batch.cobros.reverse.Cobregistro;
import com.cesce.batch.cobros.service.FtpService;



public class RegistroFtpProcessor implements ItemProcessor<Cobregistro, RegistroFTP> {

	protected final Log logger = LogFactory.getLog(getClass());

	@Autowired
	@Qualifier("ftpRegistroMockImpl")
	private FtpService frs;

	
	public RegistroFTP process(Cobregistro item) throws Exception {
		logger.info("Thread: " + Thread.currentThread().getId()+ ", procesando item " +  item.getNombreinternofichero() + " con parametro: " + item.getIdcodparametro());		 
		
		RegistroFTP rftp = new RegistroFTP();
		String fechaNotificacion = item.getFechanotificacion();
        frs.setDirectory(frs.getDirectory()+fechaNotificacion.substring(2)+"/"+fechaNotificacion+"/");
		rftp.setFtpFile(frs.getFileByName(item.getNombreinternofichero()));
		rftp.setIdRegistro(item);		
		return rftp;
		
	}
	
	
}
